Skip to content

feat: add Trae command adapter#1090

Open
jjxyxsjr wants to merge 2 commits into
Fission-AI:mainfrom
jjxyxsjr:add-trae-command-adapter
Open

feat: add Trae command adapter#1090
jjxyxsjr wants to merge 2 commits into
Fission-AI:mainfrom
jjxyxsjr:add-trae-command-adapter

Conversation

@jjxyxsjr
Copy link
Copy Markdown

@jjxyxsjr jjxyxsjr commented May 14, 2026

Summary

  • Adds a Trae command adapter that generates .trae/commands/opsx-<id>.md files
  • Updates documentation to reflect Trae command support
  • Adds unit tests (9 test cases) and integration tests for Trae command generation
  • Fixes YAML escaping for carriage returns (\r)

Context

Trae IDE now supports custom slash commands via .trae/commands/ directory. This PR adds a command adapter to align Trae with other tools (Claude, Cursor, Windsurf) that use command adapters for the opsx workflow.

The adapter generates Markdown files with YAML frontmatter (name, description) following Trae's command specification.

Changes

  1. src/core/command-generation/adapters/trae.ts - New Trae command adapter
  2. src/core/command-generation/registry.ts - Register adapter in registry
  3. test/core/command-generation/adapters.test.ts - Unit tests
  4. test/core/init.test.ts - Integration tests
  5. docs/supported-tools.md - Documentation update
  6. .gitignore - Add .trae/ entry
  7. .changeset/add-trae-command-adapter.md - Changeset

Testing

  • pnpm exec tsc --noEmit - TypeScript check passes
  • pnpm run lint - Lint passes
  • pnpm run build - Build succeeds
  • ZSH="" pnpm test - All tests pass (1496/1496)
  • openspec init --tools trae - Generates commands correctly

Related

Summary by CodeRabbit

  • New Features

    • Added TRAE IDE command adapter to generate TRAE command files for custom slash commands.
  • Documentation

    • Updated supported tools docs to reflect TRAE command adapter capabilities.
  • Tests

    • Added tests covering TRAE adapter formatting, path handling, and init behavior.
  • Chores

    • Updated ignore rules to exclude generated TRAE files.

Review Change Stack

- Added Trae command adapter for generating `.trae/commands/opsx-<id>.md` files
- Complete unit tests (9 test cases) and integration tests
- Updated documentation and .gitignore
- Fixed YAML escaping for carriage returns (\r)

Co-Authored-By: Claude Code <noreply@anthropic.com>
@jjxyxsjr jjxyxsjr requested a review from TabishB as a code owner May 14, 2026 02:50
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 14, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 7e10b1f0-81de-4788-8299-8fa15e5c8435

📥 Commits

Reviewing files that changed from the base of the PR and between b2dfeb0 and 94fc05c.

📒 Files selected for processing (2)
  • src/core/command-generation/adapters/trae.ts
  • test/core/command-generation/adapters.test.ts
🚧 Files skipped from review as they are similar to previous changes (2)
  • test/core/command-generation/adapters.test.ts
  • src/core/command-generation/adapters/trae.ts

📝 Walkthrough

Hidden review stack artifact

Walkthrough

This PR introduces a complete TRAE command adapter for generating Trae IDE command markdown files. The implementation adds a new traeAdapter that produces .trae/commands/opsx-<id>.md files with YAML frontmatter, integrates it into the command adapter registry, includes comprehensive unit and integration tests, and updates documentation to reflect the new capability.

Changes

TRAE Command Adapter Feature

Layer / File(s) Summary
TRAE Adapter Core Implementation
src/core/command-generation/adapters/trae.ts
Introduces traeAdapter with escapeYamlValue helper to safely format YAML frontmatter by quoting/escaping values containing special characters or boundary whitespace. The adapter generates .trae/commands/opsx-<id>.md paths and renders markdown with YAML frontmatter (name, description) followed by the command body.
Registry Integration
src/core/command-generation/registry.ts
Imports and registers traeAdapter in CommandAdapterRegistry's static initializer to make it available as a built-in tool command adapter.
Adapter Testing
test/core/command-generation/adapters.test.ts
Unit tests validate adapter toolId, file path generation for different command IDs, YAML frontmatter formatting with proper escaping, and handling of special characters and empty descriptions. Cross-platform path tests updated to include traeAdapter.
Integration Testing
test/core/init.test.ts
Verifies that InitCommand with delivery: 'both' and tools: 'trae' generates both skill files (.trae/skills/openspec-explore/SKILL.md) and command files (.trae/commands/opsx-explore.md) with correct YAML frontmatter.
Documentation and Configuration
.changeset/add-trae-command-adapter.md, .gitignore, docs/supported-tools.md
Changeset documents the new TRAE command adapter feature for a minor version bump. .gitignore adds .trae/ directory exclusion. docs/supported-tools.md updates Trae tool reference from "Not generated (no command adapter)" to generated command path pattern .trae/commands/opsx-<id>.md.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Possibly related PRs

  • Fission-AI/OpenSpec#853: Both PRs add a new ToolCommandAdapter by introducing a tool-specific adapter file and registering it in src/core/command-generation/registry.ts.

Suggested reviewers

  • TabishB

Poem

🐰 I hopped in with a YAML sigh,
Quoted names so values won't die,
Commands saved where Trae can see,
opsx files, neat as can be,
Hooray — markdown for you and me!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'feat: add Trae command adapter' accurately summarizes the main change—introducing a new Trae command adapter—and is concise, clear, and specific.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Tip

💬 Introducing Slack Agent: The best way for teams to turn conversations into code.

Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.

  • Generate code and open pull requests
  • Plan features and break down work
  • Investigate incidents and troubleshoot customer tickets together
  • Automate recurring tasks and respond to alerts with triggers
  • Summarize progress and report instantly

Built for teams:

  • Shared memory across your entire org—no repeating context
  • Per-thread sandboxes to safely plan and execute work
  • Governance built-in—scoped access, auditability, and budget controls

One agent for your entire SDLC. Right inside Slack.

👉 Get started


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/core/command-generation/adapters/trae.ts`:
- Around line 14-27: escapeYamlValue currently returns an unquoted empty scalar
for empty strings which YAML parses as null; add an explicit check at the start
of escapeYamlValue (the function named escapeYamlValue) to return a quoted empty
string literal (e.g. "\"\"") when value === '' before running the needsQuoting
regex/escape logic so empty-string metadata is preserved as a string in YAML
frontmatter.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 29f17e78-a3af-4ebd-9bad-402ab2170ede

📥 Commits

Reviewing files that changed from the base of the PR and between 053d8a5 and b2dfeb0.

📒 Files selected for processing (7)
  • .changeset/add-trae-command-adapter.md
  • .gitignore
  • docs/supported-tools.md
  • src/core/command-generation/adapters/trae.ts
  • src/core/command-generation/registry.ts
  • test/core/command-generation/adapters.test.ts
  • test/core/init.test.ts

Comment thread src/core/command-generation/adapters/trae.ts
- Add explicit check for empty string in escapeYamlValue
- Return quoted empty string '""' instead of unquoted empty scalar
- Update test to verify empty string is properly quoted

Co-Authored-By: Claude Code <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant